﻿#ifndef NctiDebug_H
#define NctiDebug_H
#include "ncti_base.h"
#include <stdio.h>
namespace NCTI
{
	/**
	* @brief use to debug some problems,it can output the console
	*/
	class DECL_NCTI_BASE NctiDebug
	{
	public:
		enum EnumNctiFileOpenMode
		{
			NCTI_FILE_MODE_READ
			, NCTI_FILE_MODE_WRITE
			, NCTI_FILE_MODE_APPEND
			, NCTI_FILE_MODE_APPEND_PLUS
			, NCTI_FILE_MODE_DO_NOT_OPEN
		};
	public:
		NctiDebug(const char* i_cpFullFileName, EnumNctiFileOpenMode i_eMode);
		virtual ~NctiDebug();
	public:
		/**
	   * @brief get the log file point 
	   * @return FILE*
	   */
		FILE* GetFile();
		/**
	   * @brief get the log file path
	   * @return const char*
	   */
		const char* GetFilePath();
		/**
	   * @brief write the log 
	   */
		void write(const char* i_chValue);
	public:
		/**
	   * @brief debug some information to console directly
	   * @param[in] i_ouputInfor
	   */
		static void debug(const char* i_ouputInfor);
		/**
	   * @brief debug some information to console by format
	   * @param[in] _DstBuf
	   * @param[in] _Format
	   */
		static void debug(char* _DstBuf, const char* _Format, ...);
		
		/**
		* @brief Set whether to output logs
	    * @param[in] i_val, the true or false.
		*/
		static void setOutputState(bool i_val);
		
		/**
		* @brief Get the status of whether to output logs
	    * @return bool
		*/
		static bool getOutputState();
	protected:
		FILE* m_fp;
		char* m_cpzFilePath;
		EnumNctiFileOpenMode m_Model;
		std::mutex m_mutex;
		static bool m_bOutput;
	};
}
#endif
